package com.doit.demo03;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.ServerSocket;
import java.net.Socket;

public class file_server {
    public static void main(String[] args) throws IOException {
        ServerSocket serverSocket = new ServerSocket(2021);
        Socket accept = serverSocket.accept();

        FileOutputStream fos = new FileOutputStream("C:\\Users\\DHG\\Desktop\\" + System.currentTimeMillis() + "于和伟.mp4");

        InputStream in = accept.getInputStream();
        byte[] bytes = new byte[1024];
        int len;
        while ((len=in.read(bytes))!=-1){
            fos.write(bytes,0 ,len );
        }

        OutputStream out = accept.getOutputStream();
        out.write("上传完毕".getBytes());

        out.close();
        in.close();
        fos.close();
        accept.close();
        serverSocket.close();


    }
    class method implements Runnable{

        @Override
        public void run() {

        }
    }
}
